package com.wft.adapte;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class LogAdapter implements LogFileOperateApi {
    private LogFileOperateApi logFileOperate;

    public LogAdapter(LogFileOperateApi logFileOperate) {
        this.logFileOperate = logFileOperate;
    }

    @Override
    public List<LogModel> readLogFile() {
        return logFileOperate.readLogFile();
    }

    @Override
    public void writeLogFile(List<LogModel> list) {
        logFileOperate.writeLogFile(list);
    }

    public static void main(String[] args) {
        LogFileOperateApi logFileOperate = new LogAdapter(new LogFileOperate("D:\\git\\design-pattern\\AdapterLog.log"));
        LogModel logModel = new LogModel("id1","wft",new Date(),"日志内容");
        List<LogModel> list = new ArrayList<>();
        list.add(logModel);
        list.add(logModel);
        list.add(logModel);
        logFileOperate.writeLogFile(list);

        logFileOperate.readLogFile().stream().forEach(System.out::println);
    }
}
